<?php

namespace App\Console;

use App\Console\Commands\DailyBookTotal;
use App\Console\Commands\DailyTotal;
use App\Console\Commands\GenerateAudio;
use App\Console\Commands\SendTemplate;
use App\Utils\GeneratorModelUtil;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [//
        DailyBookTotal::class,
        DailyTotal::class,
        GenerateAudio::class,
        SendTemplate::class,
    ];

    /**
     * Define the application's command schedule.
     *
     * @param \Illuminate\Console\Scheduling\Schedule $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        //GeneratorModelUtil::generatorModels();

        //每10分钟生成单词音频
        $schedule->command('gen-audio')->everyTenMinutes();

        #每10分钟统计一次日数据
        $schedule->command('daily-total')->everyTenMinutes();

        #每10分钟统计一次日数据--书本
        $schedule->command('daily-book-total --type=date')->everyTenMinutes();

        #每小时统计一次总数据--书本
        $schedule->command('daily-book-total --type=full')->hourly();

        #每日模板消息
        $schedule->command('send-template')->dailyAt('9:00');

        #每日模板消息
        $schedule->command('send-template')->dailyAt('21:00');

        //        每天执行一次
        //        $schedule->command('inspire')->daily();
        //        // 每小时执行一次
        //        $schedule->command('reports:generate')->hourly();
        //        // 每周一早上8点执行
        //        $schedule->command('emails:send')->weekly()->mondays()->at('08:00');
        //        // 每分钟执行一次
        //        $schedule->command('queue:work --stop-when-empty')->everyMinute();
        //        // 自定义 artisan 命令
        //        $schedule->command('users:cleanup')->dailyAt('02:00');
        //        // 执行 shell 命令
        //        $schedule->exec('bash /path/to/script.sh')->daily();
        //         ->between('8:00', '22:00') // 只在早上8点到晚上10点之间运行
        //         ->unlessBetween('23:00', '6:00'); // 或者排除特定时间段
        //          ->onOneServer(); // 确保在多服务器环境中只在一台服务器上运行
    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__ . '/Commands');

        require base_path('routes/console.php');
    }
}
